package com.ruoyi.project.sms.service;

import java.time.LocalDateTime;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.db.sms.mapper.SmsGrouponRulesMapper;
import com.ruoyi.db.sms.domain.SmsGrouponRules;
import com.ruoyi.db.sms.domain.query.SmsGrouponRulesQueryVo;

/**
 * 团购规则Service业务层处理
 *
 * @author yfy
 * @date 2020-04-21
 */
@Service
public class SmsGrouponRulesService
{
    @Autowired
    private SmsGrouponRulesMapper smsGrouponRulesMapper;

    /**
     * 团购状态定时检测
     *
     * @return 结果
     */
    public int smsUpdateStatus(SmsGrouponRules smsGrouponRules)
    {
        smsGrouponRules.setExpireTime(LocalDateTime.now());
        return smsGrouponRulesMapper.smsUpdateStatus(smsGrouponRules);
    }

    /**
     * 查询团购规则
     *
     * @param id 团购规则ID
     * @return 团购规则
     */
    public SmsGrouponRules selectSmsGrouponRulesById(Long id)
    {
        return smsGrouponRulesMapper.selectSmsGrouponRulesById(id);
    }

    /**
     * 查询团购规则列表
     *
     * @param smsGrouponRulesQueryVo 团购规则查询参数
     * @return 团购规则
     */
    public List<SmsGrouponRules> selectSmsGrouponRulesList(SmsGrouponRulesQueryVo smsGrouponRulesQueryVo)
    {
        return smsGrouponRulesMapper.selectSmsGrouponRulesList(smsGrouponRulesQueryVo);
    }

    /**
     * 新增团购规则
     *
     * @param smsGrouponRules 团购规则
     * @return 结果
     */
    public int insertSmsGrouponRules(SmsGrouponRules smsGrouponRules)
    {
        smsGrouponRules.setAddTime(LocalDateTime.now());
        return smsGrouponRulesMapper.insertSmsGrouponRules(smsGrouponRules);
    }

    /**
     * 修改团购规则
     *
     * @param smsGrouponRules 团购规则
     * @return 结果
     */
    public int updateSmsGrouponRules(SmsGrouponRules smsGrouponRules)
    {
        smsGrouponRules.setUpdateTime(LocalDateTime.now());
        return smsGrouponRulesMapper.updateSmsGrouponRules(smsGrouponRules);
    }

    /**
     * 批量删除团购规则
     *
     * @param ids 需要删除的团购规则ID
     * @return 结果
     */
    public int deleteSmsGrouponRulesByIds(Long[] ids)
    {
        return smsGrouponRulesMapper.deleteSmsGrouponRulesByIds(ids);
    }

    /**
     * 删除团购规则信息
     *
     * @param id 团购规则ID
     * @return 结果
     */
    public int deleteSmsGrouponRulesById(Long id)
    {
        return smsGrouponRulesMapper.deleteSmsGrouponRulesById(id);
    }
}
